//导入vue
import Vue from 'vue'
//导入路由（router）跳转视图的
import VueRouter from 'vue-router'

//导入vue视图
import Content from "../components/Content";
import Index from "../components/index";
import Login from "../views/Login"
import Main from "../views/Main";
import List from "../views/user/List";
import Add from "../views/user/add";
import Error_404 from "../views/error/Error_404";
import Email from "../views/email/Email";
import Excessive from "../views/Excessive";

//安装路由（使用路由）
Vue.use(VueRouter)

export default new VueRouter({
  //地址栏中去掉#符号
  mode:'history',
  routes:[
    {
      path:'/',
      redirect:'/login'
    },
    {
      path:'/main',
      component:Excessive,
      redirect:'main/user/list/',
      children:[
        {
          path:'user',
          name:'用户管理',
          component:Main,
          redirect:'user/list',
          children:[
            {
              path:'/main/user/list',
              name:'用户列表',
              component:List
            },{
              path:'/main/user/add',
              name:'用户添加',
              component: Add
            },
          ]
        },{
          path:'email',
          name:'邮件管理',
          redirect:'email/send',
          component:Main,
          children: [
            {
              path:'/main/email/send',
              name:'发送邮件',
              component:Email
            }
          ]
        }
      ]
    },
    {
      //路径
      path:'/content',
      //名字，可以不写
      name:'content',
      //跳转目标组件（对于导入的vue视图）
      component:Content
    },
    {
      //路径
      path:'/index',
      //名字，可以不写
      name:'index',
      //跳转目标组件（对于导入的vue视图）
      component:Index
    },
    {
      path:'/login',
      component:Login
    },
    {
      path:'/redirect__',
      //重定向
      redirect:'/login'
    },
    {
      //将其他的页面都跳到404中
      path:'*',
      component:Error_404
    }
  ]
})
